#!/bin/bash
SCRIPTSPATH=$(dirname $(readlink -f "$0"))
TOPDIR=$(realpath $SCRIPTSPATH/../../) 

option=$1

do_build(){
    xmake f -p android --ndk=~/resource/android-ndk-r25c/ -a arm64-v8a -c --require-bpftool=y
}

do_install(){
    local install_dir=$TOPDIR/install
    mkdir -p -v ${install_dir}/usr/include
    cp build/bpf ${install_dir}/usr/include/ -v -r

    mkdir -p -v ${install_dir}/lib64
    cp build/android/arm64-v8a/release/libbpf.a ${install_dir}/lib64/ -v
}

case $option in
    build)  time  do_build ;;
    install) time   do_install ;;
    *)  flag=0 ;;
esac